/*
               File: GXLRI25
        Description: Load referential integrity
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 14:36:59.13
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class gxlri25 extends GXProcedure
{
   public gxlri25( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxlri25.class ), "" );
   }

   public gxlri25( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor GXLRI252 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A189MarCod = GXLRI252_A189MarCod[0] ;
         A35PrsCod = GXLRI252_A35PrsCod[0] ;
         A445CliCod = GXLRI252_A445CliCod[0] ;
         A417PrsVeh = GXLRI252_A417PrsVeh[0] ;
         /*
            INSERT RECORD ON TABLE MMMRC10

         */
         W189MarCod = A189MarCod ;
         W189MarCod = A189MarCod ;
         W357MarNom = A357MarNom ;
         W357MarNom = A357MarNom ;
         W358MarTip = A358MarTip ;
         W358MarTip = A358MarTip ;
         W190MarEst = A190MarEst ;
         W190MarEst = A190MarEst ;
         W359MarFCR = A359MarFCR ;
         W359MarFCR = A359MarFCR ;
         W360MarHCR = A360MarHCR ;
         W360MarHCR = A360MarHCR ;
         W361MarUCR = A361MarUCR ;
         W361MarUCR = A361MarUCR ;
         W362MarFUM = A362MarFUM ;
         W362MarFUM = A362MarFUM ;
         W363MarHUM = A363MarHUM ;
         W363MarHUM = A363MarHUM ;
         W364MarUUM = A364MarUUM ;
         W364MarUUM = A364MarUUM ;
         if ( GXLRI252_n189MarCod[0] )
         {
            A189MarCod = " " ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A357MarNom))==0)) )
         {
            A357MarNom = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A358MarTip))==0)) )
         {
            A358MarTip = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A190MarEst))==0)) )
         {
            A190MarEst = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A359MarFCR)) )
         {
            A359MarFCR = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A360MarHCR))==0)) )
         {
            A360MarHCR = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A361MarUCR))==0)) )
         {
            A361MarUCR = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A362MarFUM)) )
         {
            A362MarFUM = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A363MarHUM))==0)) )
         {
            A363MarHUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A364MarUUM))==0)) )
         {
            A364MarUUM = "" ;
         }
         else
         {
         }
         /* Using cursor GXLRI253 */
         pr_default.execute(1, new Object[] {A189MarCod, A357MarNom, A358MarTip, A190MarEst, A359MarFCR, A360MarHCR, A361MarUCR, A362MarFUM, A363MarHUM, A364MarUUM});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         A189MarCod = W189MarCod ;
         A189MarCod = W189MarCod ;
         A357MarNom = W357MarNom ;
         A357MarNom = W357MarNom ;
         A358MarTip = W358MarTip ;
         A358MarTip = W358MarTip ;
         A190MarEst = W190MarEst ;
         A190MarEst = W190MarEst ;
         A359MarFCR = W359MarFCR ;
         A359MarFCR = W359MarFCR ;
         A360MarHCR = W360MarHCR ;
         A360MarHCR = W360MarHCR ;
         A361MarUCR = W361MarUCR ;
         A361MarUCR = W361MarUCR ;
         A362MarFUM = W362MarFUM ;
         A362MarFUM = W362MarFUM ;
         A363MarHUM = W363MarHUM ;
         A363MarHUM = W363MarHUM ;
         A364MarUUM = W364MarUUM ;
         A364MarUUM = W364MarUUM ;
         /* End Insert */
         /* Check if program is canceled. */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      /* Using cursor GXLRI254 */
      pr_default.execute(2);
      while ( (pr_default.getStatus(2) != 101) )
      {
         A189MarCod = GXLRI254_A189MarCod[0] ;
         A519MVehCo = GXLRI254_A519MVehCo[0] ;
         /*
            INSERT RECORD ON TABLE MMMRC10

         */
         W189MarCod = A189MarCod ;
         W189MarCod = A189MarCod ;
         W357MarNom = A357MarNom ;
         W357MarNom = A357MarNom ;
         W358MarTip = A358MarTip ;
         W358MarTip = A358MarTip ;
         W190MarEst = A190MarEst ;
         W190MarEst = A190MarEst ;
         W359MarFCR = A359MarFCR ;
         W359MarFCR = A359MarFCR ;
         W360MarHCR = A360MarHCR ;
         W360MarHCR = A360MarHCR ;
         W361MarUCR = A361MarUCR ;
         W361MarUCR = A361MarUCR ;
         W362MarFUM = A362MarFUM ;
         W362MarFUM = A362MarFUM ;
         W363MarHUM = A363MarHUM ;
         W363MarHUM = A363MarHUM ;
         W364MarUUM = A364MarUUM ;
         W364MarUUM = A364MarUUM ;
         if ( GXLRI254_n189MarCod[0] )
         {
            A189MarCod = " " ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A357MarNom))==0)) )
         {
            A357MarNom = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A358MarTip))==0)) )
         {
            A358MarTip = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A190MarEst))==0)) )
         {
            A190MarEst = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A359MarFCR)) )
         {
            A359MarFCR = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A360MarHCR))==0)) )
         {
            A360MarHCR = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A361MarUCR))==0)) )
         {
            A361MarUCR = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A362MarFUM)) )
         {
            A362MarFUM = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A363MarHUM))==0)) )
         {
            A363MarHUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A364MarUUM))==0)) )
         {
            A364MarUUM = "" ;
         }
         else
         {
         }
         /* Using cursor GXLRI255 */
         pr_default.execute(3, new Object[] {A189MarCod, A357MarNom, A358MarTip, A190MarEst, A359MarFCR, A360MarHCR, A361MarUCR, A362MarFUM, A363MarHUM, A364MarUUM});
         if ( (pr_default.getStatus(3) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         A189MarCod = W189MarCod ;
         A189MarCod = W189MarCod ;
         A357MarNom = W357MarNom ;
         A357MarNom = W357MarNom ;
         A358MarTip = W358MarTip ;
         A358MarTip = W358MarTip ;
         A190MarEst = W190MarEst ;
         A190MarEst = W190MarEst ;
         A359MarFCR = W359MarFCR ;
         A359MarFCR = W359MarFCR ;
         A360MarHCR = W360MarHCR ;
         A360MarHCR = W360MarHCR ;
         A361MarUCR = W361MarUCR ;
         A361MarUCR = W361MarUCR ;
         A362MarFUM = W362MarFUM ;
         A362MarFUM = W362MarFUM ;
         A363MarHUM = W363MarHUM ;
         A363MarHUM = W363MarHUM ;
         A364MarUUM = W364MarUUM ;
         A364MarUUM = W364MarUUM ;
         /* End Insert */
         /* Check if program is canceled. */
         pr_default.readNext(2);
      }
      pr_default.close(2);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      GXLRI252_A189MarCod = new String[] {""} ;
      GXLRI252_A35PrsCod = new String[] {""} ;
      GXLRI252_A445CliCod = new short[1] ;
      GXLRI252_A417PrsVeh = new short[1] ;
      A189MarCod = "" ;
      A35PrsCod = "" ;
      A445CliCod = 0 ;
      A417PrsVeh = 0 ;
      GX_INS25 = 0 ;
      W189MarCod = "" ;
      W357MarNom = "" ;
      A357MarNom = "" ;
      W358MarTip = "" ;
      A358MarTip = "" ;
      W190MarEst = "" ;
      A190MarEst = "" ;
      W359MarFCR = GXutil.nullDate() ;
      A359MarFCR = GXutil.nullDate() ;
      W360MarHCR = "" ;
      A360MarHCR = "" ;
      W361MarUCR = "" ;
      A361MarUCR = "" ;
      W362MarFUM = GXutil.nullDate() ;
      A362MarFUM = GXutil.nullDate() ;
      W363MarHUM = "" ;
      A363MarHUM = "" ;
      W364MarUUM = "" ;
      A364MarUUM = "" ;
      GXLRI252_n189MarCod = new boolean[] {false} ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      GXLRI254_A189MarCod = new String[] {""} ;
      GXLRI254_A519MVehCo = new short[1] ;
      A519MVehCo = 0 ;
      GXLRI254_n189MarCod = new boolean[] {false} ;
      pr_default = new DataStoreProvider(context, remoteHandle, new gxlri25__default(),
         new Object[] {
             new Object[] {
            GXLRI252_A189MarCod, GXLRI252_n189MarCod, GXLRI252_A35PrsCod, GXLRI252_A445CliCod, GXLRI252_A417PrsVeh
            }
            , new Object[] {
            }
            , new Object[] {
            GXLRI254_A189MarCod, GXLRI254_n189MarCod, GXLRI254_A519MVehCo
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A445CliCod ;
   private short A417PrsVeh ;
   private short Gx_err ;
   private short A519MVehCo ;
   private int GX_INS25 ;
   private String A189MarCod ;
   private String A35PrsCod ;
   private String W189MarCod ;
   private String W357MarNom ;
   private String A357MarNom ;
   private String W358MarTip ;
   private String A358MarTip ;
   private String W190MarEst ;
   private String A190MarEst ;
   private String W360MarHCR ;
   private String A360MarHCR ;
   private String W361MarUCR ;
   private String A361MarUCR ;
   private String W363MarHUM ;
   private String A363MarHUM ;
   private String W364MarUUM ;
   private String A364MarUUM ;
   private String Gx_emsg ;
   private java.util.Date W359MarFCR ;
   private java.util.Date A359MarFCR ;
   private java.util.Date W362MarFUM ;
   private java.util.Date A362MarFUM ;
   private IDataStoreProvider pr_default ;
   private String[] GXLRI252_A189MarCod ;
   private String[] GXLRI252_A35PrsCod ;
   private short[] GXLRI252_A445CliCod ;
   private short[] GXLRI252_A417PrsVeh ;
   private boolean[] GXLRI252_n189MarCod ;
   private String[] GXLRI254_A189MarCod ;
   private short[] GXLRI254_A519MVehCo ;
   private boolean[] GXLRI254_n189MarCod ;
}

final class gxlri25__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("GXLRI252", "SELECT [MarCod], [PrsCod], [CliCod], [PrsVehCod] FROM [MMCLI30] WITH (NOLOCK) ORDER BY [PrsCod], [CliCod], [PrsVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("GXLRI253", "INSERT INTO [MMMRC10] ([MarCod], [MarNom], [MarTip], [MarEst], [MarFCR], [MarHCR], [MarUCR], [MarFUM], [MarHUM], [MarUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
         ,new ForEachCursor("GXLRI254", "SELECT [MarCod], [MVehCod] FROM [MMVEH10] WITH (NOLOCK) ORDER BY [MVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("GXLRI255", "INSERT INTO [MMMRC10] ([MarCod], [MarNom], [MarTip], [MarEst], [MarFCR], [MarHCR], [MarUCR], [MarFUM], [MarHUM], [MarUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 10) ;
               ((short[]) buf[3])[0] = rslt.getShort(3) ;
               ((short[]) buf[4])[0] = rslt.getShort(4) ;
               break;
            case 2 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((short[]) buf[2])[0] = rslt.getShort(2) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 20);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setString(4, (String)parms[3], 1);
               stmt.setDate(5, (java.util.Date)parms[4]);
               stmt.setString(6, (String)parms[5], 8);
               stmt.setString(7, (String)parms[6], 10);
               stmt.setDate(8, (java.util.Date)parms[7]);
               stmt.setString(9, (String)parms[8], 8);
               stmt.setString(10, (String)parms[9], 10);
               break;
            case 3 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 20);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setString(4, (String)parms[3], 1);
               stmt.setDate(5, (java.util.Date)parms[4]);
               stmt.setString(6, (String)parms[5], 8);
               stmt.setString(7, (String)parms[6], 10);
               stmt.setDate(8, (java.util.Date)parms[7]);
               stmt.setString(9, (String)parms[8], 8);
               stmt.setString(10, (String)parms[9], 10);
               break;
      }
   }

}

